<?php
	//print_r($_POST);//Array ( [username] => aa [cardid] => bb [cardid1] => cc [addr] => dd [mobile] => ee [checked] => ok [submit] => submit )
	require_once('config.inc.php');//$pdo; $uid; ROOT
	//$uid = 1;
	if($uid <= 0){
		header('Refresh:3,Url=index.php');
		die('<h1>你还未登陆!!!!请登陆再来,3秒跳转到<a href="index.php">主页</a>进行登陆</h1>');
	}
	
	//查询班级表
	$sql = 'SELECT cid,cname FROM class_info';
	$stmt_class = $pdo->query($sql);
	//$result_class = $stmt_class->fetchAll(PDO::FETCH_ASSOC);
	//print_r($result_class);
	
	//查询下看有没有原信息,有就填充上去
	if($uid > 0){
		$sql = "SELECT * FROM stu_info WHERE uid=?";
		$stmt = $pdo->prepare($sql);
		$stmt->execute([$uid]);
		//$stmt_rows = $stmt->rowCount();//获取查询结果行数
		//遍历结果
		$result_all = $stmt->fetchAll(PDO::FETCH_ASSOC);
		$result_rows = count($result_all);
		//print_r($result_all);
		/*while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
		    print_r($row);
		}*/
	}
?>


<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/bootstrapValidator.min.css"/>
	<script src="js/jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/bootstrapValidator.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/language/zh_CN.js" type="text/javascript" charset="utf-8"></script>
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>鲲鹏学生信息上传</title>
<!--	<script type="text/javascript">
		$(function(){
			$('#submit').attr("disabled","true");
			$('#checked').on('change',function(){
				if($(this)[0].checked){
					$('#submit').removeAttr("disabled");
				}else{
					$('#submit').attr("disabled","true");
				}
			});
		});
	</script>-->
</head>
<body>
	<div class="panel panel-default">
		<div class="panel-heading">鲲鹏长沙学籍信息需求填写</div>
		<div class="panel-body">以下表单必须认真填写,提交成功一次即可,关系到各同学的学籍信息与以后的毕业信息！！！<br />身份证照片文件尽量不要大于1MB且尽量拍清析！！！</div>
	</div>
	<div class="container">
		<form class="form-horizontal" id="form1" action="update.php" method="post" enctype="multipart/form-data">
	        <div class="form-group">
	            <label class="col-sm-2 control-label">姓名*</label>
	            <div class="col-sm-10">
	                <input type="text" name="username" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['uname'].'"'; ?> placeholder="请输入姓名,认真核对,不要有错别字">
	            </div>
	        </div>
	        <div class="form-group">
	            <label class="col-sm-2 control-label">就读班级*</label>
	            <div class="col-sm-10">
	                <select class="form-control" name="clazz">
	                	<option value="00b">请选择</option>
	                	<!--<option value="2018php">长沙2018PHP班(原五/六班合并)</option>
	                	<option value="2018java">长沙2018JAVA班(原八班)</option>
	                	<option value="2019php">长沙2019PHP班(原九/十班合并)</option>
	                	<option value="2020php">长沙11班(包括连钢人员)</option>-->
	                	<?php  
	                	while($row = $stmt_class->fetch(PDO::FETCH_ASSOC)){
	                		if($result_rows == 1 && $result_all[0]['cid'] == $row['cid'])
	                			echo '<option selected="selected" value="'.$row['cid'].'">'.$row['cname'].'</option>';
							else
								echo '<option value="'.$row['cid'].'">'.$row['cname'].'</option>';
	                	}
	                	?>
	                	
	                </select>
	            </div>
	        </div>
	        <div class="form-group">
	            <label class="col-sm-2 control-label">身份证号码*</label>
	            <div class="col-sm-10">
	                <input type="text" name="cardid" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['cardid'].'"'; ?> placeholder="请输入身份证号码">
	            </div>
	        </div>
			<div class="form-group">
	            <label class="col-sm-2 control-label">重复输入身份证号码*</label>
	            <div class="col-sm-10">
	                <input type="text" name="cardid1" class="form-control" placeholder="请再次输入身份证号码">
	            </div>
	        </div>
	        <div class="form-group">
	            <label class="col-sm-2 control-label">身份证地址*</label>
	            <div class="col-sm-10">
	                <input type="text" name="addr" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['addr'].'"'; ?> placeholder="请输入身份证上的地址">
	            </div>
	        </div>
	        <div class="form-group">
	            <label class="col-sm-2 control-label">手机号码*</label>
	            <div class="col-sm-10">
	                <input type="text" name="mobile" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['tel'].'"'; ?> placeholder="请输入手机号码,确保能联系上本人(没有填家长的),多个号码逗号隔开">
	            </div>
	        </div>
	        <div class="form-group">
	            <label class="col-sm-2 control-label">身份证照片(头像面)*</label>
	            <div class="col-sm-10">
	                <input type="file" name="card-p"  class="form-control">
	            </div>
	        </div>
	        <div class="form-group">
	            <label class="col-sm-2 control-label">身份证照片(国徽面)*</label>
	            <div class="col-sm-10">
	                <input type="file" name="card-p1" class="form-control">
	            </div>
	        </div>
	        <hr />
	        <div class="panel panel-default">
				<!--<div class="panel-heading">鲲鹏长沙学籍信息需求填写</div>-->
				<div class="panel-body">家长联系至少填第一个(第二个为选填,但建议都填上),在有紧急情况或本人联系不上是好联系你的家长.</div>
			</div>
	        <!--家长联系电话-->
	        <div class="form-group">
	            <label class="col-sm-2 control-label">家长联系*</label>
	            <div class="col-sm-10">
	            	<div class="input-group">
	            		<span class="input-group-addon">姓名</span>
		                <input type="text" name="huname" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['h_name'].'"'; ?> placeholder="家长姓名">
		                <span class="input-group-addon">称呼</span>
		                <input type="text" name="huname1" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['h_call'].'"'; ?> placeholder="如:爸爸/妈妈">
		                <span class="input-group-addon">手机</span>
		                <input type="text" name="hmobile" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['h_tel'].'"'; ?> placeholder="家长号码,多个用逗号隔开">
	            	</div>
	            </div>
	        </div>
	        <div class="form-group">
	            <label class="col-sm-2 control-label">家长联系</label>
	            <div class="col-sm-10">
	            	<div class="input-group">
	            		<span class="input-group-addon">姓名</span>
		                <input type="text" name="huname_1" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['h1_name'].'"'; ?> placeholder="家长姓名">
		                <span class="input-group-addon">称呼</span>
		                <input type="text" name="huname1_1" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['h1_call'].'"'; ?> placeholder="如:爸爸/妈妈">
		                <span class="input-group-addon">手机</span>
		                <input type="text" name="hmobile_1" class="form-control" <?php if($result_rows == 1) echo 'value="'.$result_all[0]['h1_tel'].'"'; ?> placeholder="家长号码,多个用逗号隔开">
	            	</div>
	            </div>
	        </div>
	        
	        <div class="form-group">
	        	<div class="form-control">
	        		<label for="checked"><input type="checkbox" name="checked" id="checked" value="ok" />以上内容我已确认过,内容无误!</label>
	        	</div>
	        </div>
	        <div class="form-group">
	                <input name="submit" value="提交上面内容" type="submit" id="submit" class="form-control btn btn-success" />
	        </div>
	        
	    </form>
    </div>
</body>
<!--<script src="js/index_verify.js" type="text/javascript" charset="utf-8"></script>-->
</html>
